From 2ad0ef4632b4c2af61da4ca7a3e1d4faa0715b9d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 10 Oct 2007 08:09:13 +0000 Subject: [PATCH] Convert the format to the current locale before passing it to strtime(). 2007-10-10 Emmanuele Bassi * gtk/gtkfilechooserdefault.c (list_mtime_data_func): Convert the format to the current locale before passing it to strtime(). Fixes corrupt dates with non-UTF8 encodings on OpenSolaris. (#465380, Takao Fujiwara) svn path=/trunk/; revision=18903 --- ChangeLog | 7 +++++++ gtk/gtkfilechooserdefault.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 40777eed00..af938db8af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-10-10 Emmanuele Bassi + + * gtk/gtkfilechooserdefault.c (list_mtime_data_func): Convert + the format to the current locale before passing it to + strtime(). Fixes corrupt dates with non-UTF8 encodings on + OpenSolaris. (#465380, Takao Fujiwara) + 2007-10-10 Emmanuele Bassi * gtk/gtkfilechooserdefault.c (list_mtime_data_func): Fix the diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 47d0b81caa..33eb2648fb 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -11101,6 +11101,7 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column, struct tm tm_mtime; time_t time_now; const gchar *format; + gchar *locale_format = NULL; gchar buf[256]; #ifdef HAVE_LOCALTIME_R @@ -11143,10 +11144,14 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column, format = "%x"; /* Any other date */ } - if (strftime (buf, sizeof (buf), format, &tm_mtime) != 0) + locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL); + + if (strftime (buf, sizeof (buf), locale_format, &tm_mtime) != 0) date_str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); else date_str = g_strdup (_("Unknown")); + + g_free (locale_format); } g_object_set (cell, -- 2.30.2